#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
ll dp[30][30];

ll f(int m, int n) {
    if (dp[m][n] != 0)return dp[m][n];

    if (n == 1 || m <= 1)return dp[m][n] = 1;

    if (m < n)
        return dp[m][n] = f(m, m);
    return dp[m][n] = f(m, n - 1) + f(m - n, n);


}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        int m, n;
        cin >> m >> n;
        cout << f(m, n) << endl;
    }
    return 0;
}